<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/m/include/init_mobile.jsp" %>
<%
	if (session_user_id.equals("")) {
		response.sendRedirect("/m/member/login.jsp?os="+os);
		return;
	}

%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<title><%= HOME_NAME %></title>
	<%@ include file="/m/include/cssnjs.jsp"  %>
	<link rel="stylesheet" href="/css/jquery.mobile-1.4.2.min.css"/>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#header-nav li:nth-child(4)').addClass('on');
		
		$('input').on('keydown', function() {
			$('.error_message').text('')
		});
		
		$('.icon-delete').on('click', function() {
			$(this).closest('div').find('input').val('').focus();
			$('.error_message').text('');	
		});
	});
	

	function fnMemberOut() {
		
		if (document.frm.out_pw.value == "") {
			document.frm.out_pw.focus();
			$('.error_message').text('비밀번호를 입력하세요');
			return false;
		}

		
		$.ajax({
			url: '/member/memberOut.json',
			type: "POST",
		    dataType: 'json',
		    data:$('#frm').serialize(),
		    error: function(data, status, err){
		    	cfShowModal(err);
		    },
			success: function(data){
				if (data.result) {
					<%	if (os.equals("android")) {	%>
							window.android.logoutSuccess();
					<%	} else if (os.equals("ios")) {	%>
							window.location="jscall:logoutSuccess:";
					<%	}	%>
					document.location.href = "./memberOutSuccess.jsp?os=<%=os%>";
				}
				else {
					$('.error_message').text(data.message);
				}
		    }
		});
		
		return false;
	}
	
	</script>
</head>
<body>
	<div id="wrap">
		<%@ include file="/m/include/header.jsp"  %>
		<div id="contents">
			
			<div id="login" class="ui-page-theme-a">
				<h3><%= session_user_id %></h3>
				회원탈퇴시 구매내역 및 디바이스 정보가 삭제됩니다.<br/>
				기존에 구매한 큐북스는 다시 다운로드를 할 수 없습니다.<br/><br/>
				<div class="error_message"></div>
				<form name="frm" id="frm" method="get" action="" onsubmit="return fnMemberOut()">
					<input type="hidden" name="member_id" value="<%= session_user_id %>"/>
		        	<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear">
		        		<input type="password" name="out_pw" value="" maxlength="255" placeholder="비밀번호"/>
		        		<a href="#" class="ui-input-clear ui-btn icon-delete  ui-corner-all" ></a>
		        	</div>
		        	<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear">
		        		<input type="text" name="out_reason" value="" maxlength="255" placeholder="탈퇴사유"/>
		        		<a href="#" class="ui-input-clear ui-btn icon-delete  ui-corner-all" ></a>
		        	</div>
		        	<div class="ui-btn ui-input-btn ui-btn-active ui-corner-all ui-shadow">
						회원탈퇴하기<input type="image" alt="회원탈퇴하기" value="회원탈퇴하기"  />
					</div>
        		</form>

			</div>
			
		</div>
		<%@ include file="/m/include/footer.jsp"  %>			
	</div>

</body>

</html>









